(include-book "doublecheck" :dir :teachpacks)
(include-book "../../src/acl2/rule-creator")
(include-book "../../include/src/io-utilities")
(include-book "testing" :dir :teachpacks)


(set-state-ok t)
;;;Data generators used for testing the rule creator
;;Generate a valid birth state list --
;;dead cells with a number of neighbors
;;corresponding to a number in this list
;;will be born in the next generation
(defrandom random-birth-state-list ()
    (random-list-of (random-between 1 8)))
;;Generate a valid death state list --
;;live cells with a number of neighbors
;;corresponding to a number in this list
;;will die in the next generation
(defrandom random-death-state-list ()
    (random-list-of (random-between 0 8)))

;;Generate a random wolfram code --
;;an even integer between 0 and 255
;;that specifies an elementary ruleset.
(defrandom random-wolfram-code ()
    (* 2 (random-between 0 127)))

;;Creates a list of state association
;;items. Each item is referenced with
;;a state key and contains a string value with
;;the attribution trait.
(defun state-gen (states)
  (if (consp states)
      (cons (list "state" (rat->str (car states) 0))
            (state-gen (cdr states)))
      nil))

;;Goes through a list of states and generates
;;a list to match the given title key.
(defun state-list-gen (states key)
  (list key (state-gen states)))

;;Given a list of birth and death states
;;that are equal in size, generate an 
;;associative list of life like rule attributes.
(defun lifelike-alist-generator (birth-states death-states)
  (list (list "ruleType" "lifeLike") 
        (state-list-gen birth-states "birthStates")
        (state-list-gen death-states "deathStates")))

;;Creates the association list for the elementary
;;rule set from the given wolfram value.
(defun elementary-alist-generator (wolfram-code)
    (list (list "ruleType" "elementary")
          (list "wolframCode" (rat->str wolfram-code 0))))